package reduce.fz.com.reduce.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

import reduce.fz.com.reduce.bean.page.Pagination;

/**
 * Created by qingshengzheng on 15/8/30.
 */
public  abstract  class BaseHorizontalAdapter<VH extends BaseRecycleViewHolder,VC> extends RecyclerView.Adapter<VH> {
    protected List<VC> datas=new ArrayList<VC>();
    protected LayoutInflater layoutInflater;
    protected Context context;

    public BaseHorizontalAdapter(Context context)
    {
        this.context=context;
        this.layoutInflater=LayoutInflater.from(context);
    }
    public void initDatas(List<VC> datas)
    {
        this.datas=datas;
        notifyDataSetChanged();
    }

    public abstract VH createViewHolder(ViewGroup parent);

   @Override
    public VH onCreateViewHolder(ViewGroup parent, int viewType) {
        return createViewHolder(parent);
    }

    @Override
    public void onBindViewHolder(VH holder, int position) {
        holder.renderView(datas.get(position),position);
    }
    @Override
    public int getItemCount() {
        return datas.size();
    }
}
